//
//  HLiveShareView.m
//  linktuIOS
//
//  Created by hejunsong on 2017/1/14.
//  Copyright © 2017年 tianxie. All rights reserved.
//

#import "HLiveShareView.h"
#import "Masonry.h"
@interface HLiveShareView()
{
// KLCPopup *_pop;

}
@property (nonatomic,strong) UIView *view1;
@property (nonatomic,strong) UIView *view2;
@property (nonatomic,strong) UIView *view3;
@property (nonatomic,strong) UIView *view4;

@property(nonatomic,strong) NSArray *continerArray;

@property(nonatomic,strong) NSArray *InlandArray;

@property(nonatomic,strong) NSArray *ForeignArray;

@property(nonatomic,strong) UIButton *wxcricleButton;
@property(nonatomic,strong) UIButton *wxFriendButton;
@property(nonatomic,strong) UIButton *wbButton;
@property(nonatomic,strong) UIButton *qqFriendButton;

@property(nonatomic,strong) UIButton *fbButton;
@property(nonatomic,strong) UIButton *twitterButton;
@property(nonatomic,strong) UIButton *lineButton;

@property(nonatomic,weak) KLCPopup *pop;


@end






@implementation HLiveShareView

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
//        _pop = [KLCPopup popupWithContentView:self];
//        _pop.showType = KLCPopupShowTypeSlideInFromBottom;
//        _pop.dismissType = KLCPopupDismissTypeSlideOutToBottom;
//        _pop.maskType = KLCPopupMaskTypeClear;
        
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
        [self makePublicUI];
 
       
        [self makeInlandButtonUI];
        
       

        
        [self setupImage];
        [self addtagart];
        
    }
    
    return self;

}
-(void)shareClick:(UIButton *)but
{
    if(self.delegate && [self.delegate respondsToSelector:@selector(hliveShareView:withType:)])
    {
        switch (but.tag) {
            case 580: [self.delegate hliveShareView:self withType:HLiveSharetypeWxCricle];break;
            case 581: [self.delegate hliveShareView:self withType:HLiveSharetypeWxFriend];break;
            case 582: [self.delegate hliveShareView:self withType:HLiveSharetypeWb];break;
            case 583: [self.delegate hliveShareView:self withType:HLiveSharetypeQQ];break;
            case 584: [self.delegate hliveShareView:self withType:HLiveSharetypeFB];break;
            case 585: [self.delegate hliveShareView:self withType:HLiveSharetypeTwitter];break;
            case 586: [self.delegate hliveShareView:self withType:HLiveSharetypeLine];break;
            default: break;
        }
    
    
    
    }
    
    

}


-(void)addtagart
{
    [self.wxFriendButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.fbButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.twitterButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.wbButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.qqFriendButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.wxcricleButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.lineButton addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];


}

-(void)setupImage
{
    [self.twitterButton setImage:[UIImage imageNamed:@"icon_tweet_share_live"] forState:UIControlStateNormal];
    [self.fbButton setImage:[UIImage imageNamed:@"icon_facebook_share_live"] forState:UIControlStateNormal];
    [self.wxcricleButton setImage:[UIImage imageNamed:@"icon_wechat_friend_share_live"] forState:UIControlStateNormal];
    [self.wxFriendButton  setImage:[UIImage imageNamed:@"icon_wechat_share_live"] forState:UIControlStateNormal];
    [self.qqFriendButton setImage:[UIImage imageNamed:@"icon_qq_share_live"] forState:UIControlStateNormal];
    [self.wbButton setImage:[UIImage imageNamed:@"icon_weibo_share_live"] forState:UIControlStateNormal];
    [self.lineButton setImage:[UIImage imageNamed:@"share-line_live"] forState:UIControlStateNormal];
    

}
-(void)makeInlandButtonUI
{
    _wxFriendButton = [UIButton new];
    _wxcricleButton = [UIButton new];
    _wbButton = [UIButton new];
    _qqFriendButton = [UIButton new];
    
    _wxcricleButton.tag = 580;
    _wxFriendButton.tag = 581;
    _wbButton.tag =       582;
    _qqFriendButton.tag = 583;
    
    
    [_view1 addSubview:_wxcricleButton];
    [_view2 addSubview:_wxFriendButton];
    [_view3 addSubview:_wbButton];
    [_view4 addSubview:_qqFriendButton];
    
    [_wxFriendButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_view2.centerX).offset(0);
        make.centerY.mas_equalTo(_view2.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_wxcricleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_view1.centerX).offset(0);
        make.centerY.mas_equalTo(_view1.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_wbButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_view3.centerX).offset(0);
        make.centerY.mas_equalTo(_view3.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_qqFriendButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_view4.centerX).offset(0);
        make.centerY.mas_equalTo(_view4.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
}

-(void)makeForeignButtonUI
{
//    _wxFriendButton = [UIButton new];
    _wxFriendButton = [UIButton new];
    _fbButton = [UIButton new];
    _twitterButton = [UIButton new];
    _lineButton = [UIButton new];
    
//    _wxcricleButton.tag = 580;
    _wxFriendButton.tag = 581;
    _fbButton.tag =       584;
    _twitterButton.tag = 585;
    _lineButton.tag = 586;
    
    [_view1 addSubview:_twitterButton];
    [_view2 addSubview:_fbButton];
    [_view3 addSubview:_wxFriendButton];
    [_view4 addSubview:_lineButton];
    
    [_wxFriendButton mas_makeConstraints:^(MASConstraintMaker *make) {  //4
        make.centerX.mas_equalTo(_view4.centerX).offset(0);
        make.centerY.mas_equalTo(_view4.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_lineButton mas_makeConstraints:^(MASConstraintMaker *make) {  //3
        make.centerX.mas_equalTo(_view3.centerX).offset(0);
        make.centerY.mas_equalTo(_view3.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_fbButton mas_makeConstraints:^(MASConstraintMaker *make) {  //2
        make.centerX.mas_equalTo(_view2.centerX).offset(0);
        make.centerY.mas_equalTo(_view2.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    [_twitterButton mas_makeConstraints:^(MASConstraintMaker *make) {  //1
        make.centerX.mas_equalTo(_view1.centerX).offset(0);
        make.centerY.mas_equalTo(_view1.centerY).offset(0);
        make.width.equalTo(@40);
        make.height.equalTo(@40);
    }];
    
    
    
    
}




-(void)makePublicUI
{
    _view1 = [UIView new];
    _view2 = [UIView new];
    _view3 = [UIView new];
    _view4 = [UIView new];
    
    [self addSubview:_view1];
    [self addSubview:_view2];
    [self addSubview:_view3];
    [self addSubview:_view4];
    
//    _view1.backgroundColor = [UIColor redColor];
//    _view2.backgroundColor = [UIColor grayColor];
//    _view3.backgroundColor = [UIColor brownColor];
//    _view4.backgroundColor = [UIColor purpleColor];
    
    [_view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.top.mas_equalTo(self.mas_top).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
    }];
    
    [_view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_view1.mas_right).offset(0);
        make.top.mas_equalTo(_view1.mas_top).offset(0);
        make.height.equalTo(_view1.mas_height);
        make.width.equalTo(_view1.mas_width);
    }];
    
    [_view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_view2.mas_right).offset(0);
        make.top.mas_equalTo(_view2.mas_top).offset(0);
        make.height.equalTo(_view2.mas_height);
        make.width.equalTo(_view2.mas_width);
    }];
    
    [_view4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_view3.mas_right).offset(0);
        make.top.mas_equalTo(_view3.mas_top).offset(0);
        make.height.equalTo(_view3.mas_height);
        make.width.equalTo(_view3.mas_width);
         make.right.mas_equalTo(self.mas_right).offset(0);
        
    }];
    
}


-(void)show
{

    KLCPopup    *pop = [KLCPopup popupWithContentView:self];
                pop.showType = KLCPopupShowTypeSlideInFromBottom;
                pop.dismissType = KLCPopupDismissTypeSlideOutToBottom;
                pop.maskType = KLCPopupMaskTypeClear;
                self.pop = pop;
    [pop showAtCenter:CGPointMake(WIDTH/2.0, HEIGHT - self.frame.size.height/2) inView:[[UIApplication sharedApplication].delegate window]];
}

-(void)dismis
{
    [self.pop dismiss:YES];
}
-(void)dealloc
{
    NSLog(@"dealloc --shareView");
    
}
@end
